package csel.view;

import java.awt.event.ActionListener;
import java.awt.event.KeyListener;

import javax.swing.JFrame;

import csel.model.GameCommand;
import csel.model.Model;
import csel.model.Item;
import csel.model.Entity;

/**
 * Reasons for Existence:
 * Team Members Responsible
 * Implementation: Alex, Andrew
 * Testing: Alex, Andrew    
 */
public class StatusViewport extends Viewport
{

	//the viewport's window
	JFrame myWindow;

	//component Viewers
	AvatarViewer aViewer;
	EquipmentViewer eViewer;
	InventoryViewer iViewer;
	StatsViewer sViewer;
	
	private final Entity player;


	public StatusViewport(Model m)
	{
		player = m.getPlayerEntity();
		aViewer = new AvatarViewer(player);
		eViewer = new EquipmentViewer(player,);
		iViewer = new InventoryViewer(player,);
		sViewer = new StatsViewer(player);
		myWindow = new JFrame();
		myWindow.add(aViewer);
        myWindow.add(sViewer);
        myWindow.add(iViewer);
        myWindow.add(eViewer);
        myWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        myWindow.setSize(400,400);
        myWindow.setLocation(200,200);
        setVisible(true);
	}

	public void setVisible(boolean b)
	{
		myWindow.setVisible(b);
	}

	public void close()
	{
		myWindow.remove(aViewer);
		myWindow.remove(eViewer);
		myWindow.remove(iViewer);
		myWindow.remove(sViewer);
		aViewer = null;
		eViewer = null;
		iViewer = null;
		sViewer = null;
		setVisible(false);
	}

	public void accept(GameCommand g)
	{
		g.execute();
	}

	public Item[] getSelectedInventoryItems()
	{
		return iViewer.getSelectedItems();
	}
	
	public Item[] getSelectedEquipmentItems()
	{
		return eViewer.getSelectedItems();
	}
}
